
new Vue({
 el:'#animeInfo_C',
 data:{
   animeInfo:{},
   spanClass1:'active',
   spanClass2:'',
   episodesNum:0,
   episodesStartNum:0,
   id:'',
   updateType:0,
   panUrl:'',
 },
 methods:{
   readFile(){
     let id = getUrlParams().id;
     this.id = id;
     this.$http.get('./moongoDB/animes').then(response =>{
       let res = response.body;
       if(res){
         let animes = res;
         this.animeInfo = animes.filter( anime => {
            return anime.id == this.id;
         })[0];  
          
         // 标题替换
         document.title = `${this.animeInfo.title} | Z-anime`;

         // 集数    
         this.episodesNum = this.animeInfo.episodes.length;
         
         // 第几集开始正片       
         this.episodesStartNum = this.animeInfo.start; 

         // 连载还是完结类型
         this.updateType = this.animeInfo.update;   
        
         // 下载链接
         this.panUrl = this.animeInfo.panUrl;  
         
       }
     },response=>{
       console.log('请求数据失败！');  
     });
   },
   // 切换按钮
   switchClick1(){ 
     this.spanClass1 = 'active';
     this.spanClass2 = '';
     $('.online').removeClass('hide');
     $('.download').addClass('hide');
   },
   switchClick2(){
    this.spanClass2 = 'active';
    this.spanClass1 = '';
    $('.online').addClass('hide');
    $('.download').removeClass('hide');
  },
  // 去主页
  toIndexClick(){
    window.location.href='/';
  },
  // 去番剧
  toAnimeClick(){
    window.location.href='/anime';
  },
  // 去播放
  toPlayClick(){
    window.open(`/animeVideo?id=${this.id}&&p=${this.episodesStartNum + 1}`,'_blank');  
  },
   // 集数导航
   hrefClick(index){ 
     window.open(`/animeVideo?id=${this.id}&&p=${index + 1 }`,'_blank');  
   }
 },

 beforeCreate(){
  
 },

 created(){
  this.readFile();
  // 简介
  $('.urlTitle').html(`{{animeInfo.title}}`);
  $('.title').html(`{{animeInfo.title}}`);
  $('.zValue').html(`热度值：{{animeInfo.zValue}}`);
  $('.content').html(`简介：{{animeInfo.content}}`);
  $('.tags').html(`<span class="tags_item" v-for="(item,index) in animeInfo.tags" :key="index">{{item}}</span>
  <span class="area">{{animeInfo.area}}</span>`);    
  $('.content').before(`<div class="date" v-if="updateType==0">{{animeInfo.year}}年{{animeInfo.month}}月{{animeInfo.day}}日 开播&nbsp;&nbsp;&nbsp;已完结，全{{animeInfo.episodes.length}}集</div>
  <div class="date" v-else>{{animeInfo.year}}年{{animeInfo.month}}月{{animeInfo.day}}日 开播&nbsp;&nbsp;&nbsp;连载中，每{{animeInfo.updateDate}}更新</div>`);
   
  // 集数
  $('.online').html(`
    <span v-for="(item,index) in animeInfo.episodes" @click="hrefClick(index)">
    <div v-if="index < episodesStartNum">
    <div class="ovh">
      <div>
        第{{item.title}}话
      </div>
      <div>无</div>
      </div>
    </div>

    <div v-else>
     <div class="ovh">
      <div>
          第{{index-episodesStartNum+1}}话
      </div>
      <div class="title" :title="item.title">{{item.title}}</div></div>
     </div>
    <div class="notice" :style="{'display':index + 1 == episodesNum ? 'block':'none'}">最新</div>
  </span>  
    `);
   // 下载
    
 },
 beforeMount(){   
   
},
 mounted(){   
   
 },
 updated(){
   
 }
 
});